//统一验证，验证发布商品的数据是否符合规范
const validator =async (ctx,next)=>{
    try {

        //基于parameter库来验证
        ctx.verifyParams({
            goods_name:{type:'string',required:true},
            goods_img: {type: 'string',required:false },
            goods_price:{type:'number',required:true},
            goods_num:{type:'number',required:true},
            goods_classify:{type:'number',required:true}
        })

    }catch (err){

       return  ctx.body={
            err:"参数格式不对"
        }
    }
    return next()

}
module.exports={
    validator
}